window.onload = function () {
	//swiper初始化
	var swiper = new Swiper('.swiper-container',{
			direction:'vertical',
			onInit: function(swiper) { //Swiper2.x的初始化是onFirstInit
				swiperAnimateCache(swiper); //隐藏动画元素 
				swiperAnimate(swiper); //初始化完成开始动画			
			},
			onSlideChangeEnd: function(swiper) {
				swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
			}
		});
	
	//动画开始
	var clouds = [];
	var item;
	for ( var i = 4; i < 8; i++ ) {
		item = '.c-' + i;
		clouds.push(document.querySelector(item));
	}
	
	var sunshine = [];

	sunshine.push(document.querySelector('.sunshine-1'));
	sunshine.push(document.querySelector('.sunshine-2'));

	var c_2 = document.querySelector('.c-2');
	var start_x,start_y,end_x,end_y;
	document.addEventListener('touchstart', function (e) {
		start_x = e.targetTouches[0].pageX;
		start_y = e.targetTouches[0].pageY;
		console.log(e);
	});
	var bg = document.querySelector('.page-1');
	
	document.addEventListener('touchmove', function (e) {
		
		end_x = e.targetTouches[0].pageX;
		end_y = e.targetTouches[0].pageY;
		page_1Ani();
		function page_1Ani(){
			if ( end_x > start_x) {
				sunshine[0].style.width = 10 + 'rem';
				sunshine[0].style.height = 10 + 'rem';
				sunshine[1].style.width = 10 + 'rem';
				sunshine[1].style.height= 10 + 'rem';
				setTimeout( function () {
					c_2.style.left = -6.25 + 'rem';
					c_2.style.transition = 'left 300ms linear ';
					clouds[0].style.right = -3 + 'rem';
					clouds[0].style.transition = 'left 300ms linear ';
					clouds[1].style.right = -3.75 + 'rem';
					clouds[1].style.transition = 'left 300ms linear ';
					clouds[2].style.left = -2.5 + 'rem';
					clouds[2].style.transition = 'left 300ms linear ';
					clouds[3].style.left = -6.75 + 'rem';
					clouds[3].style.transition = 'left 300ms linear ';
				},1000);
				bg.style.background = 'white';
				setTimeout(function () {
					bg.style.background = '#4b4b4b';
				},300);
			}
			
		}

	});
	
}
